{extend name="public/header" /}
{block name="body"}
<body>
{include file="public/common" /}
<div class="layui-form">
    <table class="layui-table" lay-size="sm">
        <thead>
        <tr>
            <th width="80px">ID</th>
            <th>名称</th>
            <th>下辖管理员</th>
            <th>状态</th>
            <th width="200">操作</th>
        </tr>
        </thead>
        <tbody>
        {if(count($list)<1)}
        <tr>
            <td colspan="5" align="center">暂无相关数据</td>
        </tr>
        {else /}
        {foreach name="list" item="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.name}</td>
            <td>{$vo.userCount}</td>
            <td><input type="checkbox" lay-skin="switch" lay-filter="switch" value="{$vo.status}" lay-text="正常|禁用" {if $vo.status==1}checked{/if} data-url='{:url("ajax/upField",array("table"=>"admin_role","id_name"=>"id","id_value"=>$vo["id"],"field"=>"status"))}'></td>
            <td>
                <a class="layui-btn layui-btn-xs layui-btn-normal" href="{:url('role/purview',array('id'=>$vo['id']))}">
                    <i class="layui-icon">&#xe672;</i>权限
                </a>
                <a class="layui-btn layui-btn-xs modal-catch" href="{:url('role/info',array('id'=>$vo['id']))}">
                    <i class="layui-icon">&#xe642;</i>编辑
                </a>
                {if $vo.id != 1 && $vo.userCount == 0}
                <a class="layui-btn layui-btn-xs layui-btn-danger ajax-del" data-url='{:url("role/del")}' data-field='id' data-value='{$vo.id}'>
                    <i class="layui-icon">&#xe640;</i>删除
                </a>
                {/if}
            </td>
        </tr>
        {/foreach}
        {/if}
        </tbody>
    </table>
</div>
<div class="text-right">
    <div class="layui-box layui-laypage layui-laypage-molv" id="layui-laypage">
        {$_page|raw}
    </div>
</div>
</body>
{/block}
{block name="script"}
<script>
layui.use(['form', 'layajax'], function () {
    var form = layui.form
        , layajax = layui.layajax;

    form.render();
});
</script>
{/block}